//每次调用$.ajax的时候会优先调用这个函数，可以拿到Ajax给的配置对象
$.ajaxPrefilter(function(options) {
    //发起Ajax之前，统一拼接真正的url路径
    options.url = 'http://www.liulongbin.top:3007' + options.url
    if (options.url.indexOf('/my/') !== -1) {
        if (options.headers) options.headers.Authorization = localStorage.getItem('token')
        else options.headers = {
            Authorization: localStorage.getItem('token')
        }
    }
    options.complete = function(res) {
        if (res.responseJSON.status === 1 && res.responseJSON.message === '身份认证失败！') {
            layui.layer.confirm('登录失效，请重新登录', { icon: 3, title: '提示' }, (index) => {
                localStorage.removeItem('token')
                location.href = '/login.html'
            })
        }
    }

})